﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZedGraph;

namespace Dijkstra_Belman_Ford
{
    public partial class Form2 : Form
    {
        Form1 form1;

        public Form2(Form1 form1)
        {
            this.form1 = form1;
            InitializeComponent();
            CreateGraph(zedGraphControl1);
            SetSize();

        }

        private void SetSize()
        {
            zedGraphControl1.Location = new Point(10, 10);
            zedGraphControl1.Size = new Size(this.Width - 20,this.Height - 20);
        }

   
        private void CreateGraph(ZedGraphControl zgc)
        {
            GraphPane pane = zgc.GraphPane;
            pane.Title.Text = "Wykres szybkości działania algorytmów";
            pane.XAxis.Title.Text = "Czas w ms";
            pane.YAxis.Title.Text = "Ilość krawędzi";

            double x1,x2, y;
            PointPairList list1 = new PointPairList();
            PointPairList list2 = new PointPairList();
            for (int i = 0; i < form1.counter; i++)
            {
                y = form1.egdges[i];
                x1 = form1.time1[i];
                x2 = form1.time2[i];
                list1.Add(x1,y);
                list2.Add(x2,y);
            }
            
            LineItem myCurve = pane.AddCurve("Dijkstra",list1, Color.Red);
            LineItem myCurve2 = pane.AddCurve("Bellman-Ford",list2, Color.Blue);
            zgc.AxisChange();

        }

    }
}
